﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HKEA.CMS.Core.IDAL.Tbl;
using HKEA.CMS.Core.Models;
using HKEA.CMS.Core.DALFactory;
using HKEA.CMS.Core.Utility;

namespace HKEA.CMS.Core.BLL.Tbl
{
    public class tblMediaRoomBLL
    {
        private ItblMediaRoom IDAL;

        public tblMediaRoomBLL()
        {
            IDAL = DataAccess.CreateItblMediaRoom();
        }

        /// <summary>
        /// 创建对象
        /// </summary>
        /// <returns></returns>
        public static tblMediaRoomBLL GetInstance()
        {
            return new tblMediaRoomBLL();
        }

        public tblMediaRoom GetEntity(int uid)
        {
            try
            {
                return IDAL.GetEntity(uid);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public tblMediaRoom GetLastEntity()
        {
            try
            {
                return IDAL.GetLastEntity();
            }
            catch (Exception)
            {
                throw;
            }
        }

        public List<tblMediaRoom> GetListByENT(tblMediaRoom ent)
        {
            List<tblMediaRoom> list = new List<tblMediaRoom>();
            if (ent != null)
            {
                try
                {
                    list = IDAL.GetListByENT(ent);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return list;
        }

        public List<MediaRoomList> GetList(tblMediaRoom ent, List<int> WithOutList)
        {
            List<MediaRoomList> list = new List<MediaRoomList>();
            if (ent != null)
            {
                try { list = IDAL.GetList(ent, WithOutList); }
                catch (Exception er) { throw; }
            }
            return list;
        }

        public List<tblMediaRoom> GetListByENT(tblMediaRoom ent, PageParam param, string strPropertyName, string strOrderBy)
        {
            List<tblMediaRoom> list = new List<tblMediaRoom>();
            if (ent != null && param != null)
            {
                try
                {
                    list = IDAL.GetListByENT(ent, param, strPropertyName, strOrderBy);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return list;
        }

        public int GetCountByENT(tblMediaRoom ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.GetCountByENT(ent);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return ret;
        }

        public int InsertENT(tblMediaRoom ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.InsertENT(ent);
                }
                catch (Exception)
                {

                    throw;
                }
            }
            return ret;
        }

        public int UpdateENT(tblMediaRoom ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.UpdateENT(ent);
                }
                catch (Exception)
                {

                    throw;
                }
            }
            return ret;
        }

        public int DeleteENT(tblMediaRoom ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.DeleteENT(ent);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return ret;
        }

        public int DeleteENT(int uid)
        {
            tblMediaRoom ent = new tblMediaRoom();
            ent.MediaRoomUID = uid;
            return DeleteENT(ent);
        }
    }
}
